﻿Imports System.Windows.Forms

Public Class FrmMainForm

    Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
        'Me.Close()
        'Application.Exit()
        End


    End Sub



    Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub

    Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub

    Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub

  

    Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Close all child forms of the parent.
        For Each ChildForm As Form In Me.MdiChildren
            ChildForm.Close()
        Next
    End Sub

   
    Public Sub ShowChildForm(ByVal Frm As Form)
        Dim ChildForm As New Form
        For Each ChildForm In Me.ActiveForm.MdiChildren()
            If ChildForm.Name = Frm.Name Then
                ChildForm.Activate()
                Exit Sub
            End If
        Next
        Frm.MdiParent = Me.ActiveForm
        Frm.Show()
    End Sub

    Private Sub mniThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniThoat.Click
        MaNVDangNhap = ""
        TenNVDangNhap = ""
        khach = ""
        Dim frm As New frmLogin
        frm.MdiParent = Me.MdiParent
        frm.Show()
        Me.Visible = False

        Admin.Close()
        frmThongTinNV.Close()
        'frmThongKeNgay.Close()
        'frmThongKeThang.Close()
        'frmThongKeTon.Close()
        frmXuatKho.Close()
        Frm_HoaDonNhapKho.Close()
        Frm_DanhMucSanPham.Close()

        'frmThongTinSanPham.Close()
        FrmCongtyKH.Close()
        frmNCC.Close()
        ' frmThongTinNV.Close()
        Me.mniNhap.Enabled = True
        Me.mniQLSP.Enabled = True
        Me.mniAdmin.Enabled = True
        Me.mniXuat.Enabled = True
        Me.mniNCC.Enabled = True
        Me.mniKH.Enabled = True
    End Sub

    Private Sub mniQLSP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniQLSP.Click
        ShowChildForm(Frm_DanhMucSanPham)
    End Sub

    Private Sub mniAdmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniAdmin.Click
        ShowChildForm(Admin)
    End Sub

    Private Sub mniUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniUser.Click
        ShowChildForm(frmThongTinNV)
    End Sub

    Private Sub mniNhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniNhap.Click
        ShowChildForm(Frm_HoaDonNhapKho)
    End Sub

    Private Sub mniXuat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniXuat.Click
        ShowChildForm(frmXuatKho)
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        frmGioiThieu.ShowDialog()
    End Sub


    Private Sub mniNCC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniNCC.Click
        ShowChildForm(frmNCC)
    End Sub

    Private Sub mniKH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniKH.Click
        ShowChildForm(FrmCongtyKH)
    End Sub

    Private Sub FrmMainForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        ' Application.Exit()
        End
    End Sub

    Private Sub ThốngKêSảnPhẩmToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThốngKêSảnPhẩmToolStripMenuItem.Click
        ShowChildForm(FrmThongKeTon)
    End Sub

 
    Private Sub ThốngKêHóaĐơnNhậpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThốngKêHóaĐơnNhậpToolStripMenuItem.Click
        ShowChildForm(Frm_ThongKeHoaDonNHap)
    End Sub

    Private Sub ThốngKêHóaĐơnXuấtToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThốngKêHóaĐơnXuấtToolStripMenuItem.Click
        ShowChildForm(Frm_ThongKeHoaDonXuat)
    End Sub

    Private Sub ThốngKêTheoNgàyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThốngKêTheoNgàyToolStripMenuItem.Click
        ShowChildForm(frmThongKeNgay)
    End Sub
End Class
